﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Windows.Controls.DataVisualization.Charting;
using System.Data.SqlClient;
using System.Data;

namespace luanvanFinal
{
    /// <summary>
    /// Interaction logic for wdRiskFirst.xaml
    /// </summary>
    public partial class wdRiskFirst : Window
    {
        private int idProject;
        public wdRiskFirst()
        {
            InitializeComponent();
            //showColumChart();
        }
        

        public int IdProject
        {
            get { return idProject; }
            set { idProject = value; }
        }

        public void showColumChart()
        {
            
            String strSQL = "select sumCos,sumBus,sumImp,sumQua from risk where idProject = '"+this.IdProject+"' order by ID ";
            clsConnect ketnoi = new clsConnect();
            ketnoi.openConnection();
            SqlDataAdapter da = new SqlDataAdapter(strSQL, ketnoi.Connection);
            DataTable dt = new DataTable();
            da.Fill(dt);
            
            ((ColumnSeries)mcChart.Series[0]).ItemsSource =
                new KeyValuePair<string, int>[]{
            new KeyValuePair<string, int>("Customer", Convert.ToInt32(dt.Rows[dt.Rows.Count-1][0].ToString())),
            new KeyValuePair<string, int>("Business analyst", Convert.ToInt32(dt.Rows[dt.Rows.Count-1][1].ToString())),
            new KeyValuePair<string, int>("Implement", Convert.ToInt32(dt.Rows[dt.Rows.Count-1][2].ToString())),
            new KeyValuePair<string, int>("Quality assurance", Convert.ToInt32(dt.Rows[dt.Rows.Count-1][3].ToString()))
        
            };
            ketnoi.closeConnection();
        }

        private void btnChartCus_Click(object sender, RoutedEventArgs e)
        {
            wdChartCus chartCus = new wdChartCus();
            chartCus.Show();
        }

        private void btnChartImp_Click(object sender, RoutedEventArgs e)
        {
            wdChartImp chartImp = new wdChartImp();
            chartImp.Show();
        }

        private void btnChartBus_Click(object sender, RoutedEventArgs e)
        {
            wdChartBus chartBus = new wdChartBus();
            chartBus.Show();
        }

        private void btnChartQua_Click(object sender, RoutedEventArgs e)
        {
            wdChartQua chartQua = new wdChartQua();
            chartQua.Show();
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            showColumChart();
        }
    }
}
